import React,{Suspense} from "react"
import {BrowserRouter,Routes,Route,Navigate} from "react-router-dom"
import routerList from "./routerList"
function RouterView () {
    const renderRouter = (arr)=>{
       let aaa = arr.map((item,index)=>{
            return item.path ? <Route key={index} path={item.path} element={<item.component></item.component>}>
                    {
                        item.children && renderRouter(item.children)
                    }
            </Route>:<Route key={index} path={item.from} element={<Navigate to={item.to}></Navigate>}></Route>
        })
       return aaa
    }

    return (
        <BrowserRouter>
            <Suspense fallback={<div>...loading</div>}>
                <Routes>
                    {
                        renderRouter(routerList)
                      
                    }
                </Routes>
            </Suspense>     
        </BrowserRouter>
      
    )

}
export default RouterView

